// pages/mine/mine.js
Page({
  /**
   * Page initial data
   */
  data: {
     dint:'',
     civilian:'',
  },

  /**
   * Lifecycle function--Called when page load
   */
  onLoad: function (options) {

  },
  onReady: function () {
   
  },

  /**
   * Lifecycle function--Called when page show
   */
  onShow: function () {
    
  },
  Typing1: function (e) {
    var dint = e.detail.value;
    this.setData({
      dint
    })
  },
  Typing2: function (e) {
    var civilian = e.detail.value;
    this.setData({
     civilian
    })
  },
  submit(){
    if (this.data.civilian != '' && this.data.dint != '') {
     wx.request({
       url: 'https://www.haofanhudong.cn:8442/word/addWord',
       data:{
         word_mole:this.data.dint,
         word_commoner:this.data.civilian
       },
       header: { 'content-type': 'application/x-www-form-urlencoded' },
       method: 'POST',
       success: function (res) {
         var resData = res.data;
         if (resData.status == "error") {
           wx.showToast({
             title: '返回数据有误！',
           })
           return;
         }else{
           wx.showToast({
             title: '提交词语成功',
           })
           console.log(res);
         }
       },
       fail: function (res) {
         wx.showToast({
           title: '请求失败！',
         })
         return; 
       },
    
     })
    this.setData({
      dint: '',
      civilian: '',
     
    });
    }else{
      wx.showToast({
        title: '请填写完整',
        icon: 'none',
      })
    }
  },
  onShareAppMessage: function () {

  }
})